<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- basic styles -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css" />
<link rel="stylesheet" href="assets/css/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="assets/css/font-awesome.min.css" />
<link rel="stylesheet" href="assets/css/ace.min.css" />

</head>
<body>
	<div class="main-container" id="main-container">
		<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<div class="breadcrumbs" id="breadcrumbs">
					<script type="text/javascript">
						try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
					</script>
					
				<ul class="breadcrumb">
					<li><i class="icon-home home-icon"></i> <a>账号管理</a></li>
					<li class="active">分组管理</li>
				</ul>
				
				<!-- .breadcrumb -->
				<div class="nav-search" id="nav-search" style="vertical-align: top;">
						 <form id="searchForm" class="form-search"
							action="agent/agent_page_list.do" method="post">
							<span class="input-icon"> <input type="text" name="companyName"
							value="${companyName }" placeholder="输入供应商名称 ..." class="nav-search-input"
							id="nav-search-input" autocomplete="off" /> 
						</span> 
						<button id="btnSearch" type="button" class="btn btn-info btn-sm">
							<i class="icon-search icon-only"></i>
						</button>
							<input type="hidden" name="pageNumber" value="1" />
						</form> 
					</div>
					<!-- #nav-search -->
				</div>
				<div class="page-content">
					<div class="page-header">
						<b>分组列表</b>
					</div>
					
					<!-- /.page-header -->
					<!-- PAGE CONTENT BEGINS -->
					<div class="row">
						<div class="col-xs-12">
							<div class="table-responsive">
								<table id="sample-table-1"
									class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th class="center"><label><input type="checkbox"
													class="ace" /><span class="lbl"></span> </label></th>
											<th>供应商名称</th>
											<th>法人</th>
											<th>供应商地址</th>
											<th>供应商手机号</th>
											<th>供应商联系人</th>
											<th>联系人手机号</th>
											<th>联系人邮箱</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody>
										<c:forEach items="${agentList}" var="agent">
											<tr>
												<td class="center"><label><input
														type="checkbox" name="IDCK" class="ace"
														value="${agent.id}" /><span class="lbl"></span> </label></td>
												<td>${agent.companyName}</td>
												<td>${agent.legalPerson}</td>
												<td>${agent.companyAddress}</td>
												<td>${agent.companyPhone}</td>
												<td>${agent.contactPeople}</td>
												<td>${agent.contactPhone}</td>
												<td>${agent.contactEmail}</td>
												<td>
													<div
														class="visible-md visible-lg hidden-sm hidden-xs btn-group">
														<button id="id-btn-dialog2" onclick="edit(${agent.id})"
															class="btn btn-xs btn-info">
															<i class="icon-edit bigger-120"></i>
														</button>
														<button class="btn btn-xs btn-info"
															onclick="del('${agent.id}')">
															<i class="icon-trash bigger-120"></i>
														</button>
													</div>
												</td>
											</tr>
										</c:forEach>
									</tbody>
								</table>
						</div>
						<!-- /.table-responsive -->
					</div>
					<!-- /span -->
				</div>
				<!-- /row -->
				<div style="height: 35px;">
					<div style="float: left;">
						<button id="btn_add"  class="btn btn-sm btn-info">
							<i class="icon-edit bigger-120"></i>添加
						</button>
						<button id="btn_del" class="btn btn-sm btn-info">
							<i class="icon-trash bigger-120 icon-only"></i>
						</button>
						<button id="btn_fresh"  onclick="formFresh();" class="btn btn-sm btn-info">
							<i class="icon-refresh bigger-120 icon-only"></i>
						</button>
					</div>
					<%@ include file="page.jsp"%>
				</div>
			</div>
			<!-- /.page-content -->
		</div>
		<!-- /.main-container-inner -->
	</div>
	<!-- /.main-container -->
	<script src="assets/js/ace-extra.min.js"></script>
<script type="text/javascript" src="assets/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/chosen.jquery.min.js"></script>
	<script type="text/javascript">
			$('table th input:checkbox').on('click' , function(){
				var that = this;
				$(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function(){
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});
			});
			$( "#btnSearch" ).on('click', function(e) {
				$("#searchForm").submit();
			});
			function formFresh() {
				$("#searchForm").submit();
			}
			
			$( "#btn_add" ).on('click', function(e) {
				window.parent.showDialog("添加供应商信息",'<%=basePath%>agent/agent_add.do',400,430);
			});
			$( "#btn_del" ).on('click', function(e) {
				var ids = '';
				$sel = $("input:checkbox[name='IDCK']:checked");
				if($sel.length == 0){
					window.parent.showConfirm("请选择删除记录 !!!");	
				}else {
					var len =$sel.length;
					$sel.each(function(){
						ids += this.value + ",";
					});
					var yes = function() {
						var url = '<%=basePath %>agent/agent_delAll.do?ids='+ids;
						$.post(url,function(){
							$("#searchForm").submit();
						});
					};
					window.parent.showConfirm("你确定要删除以上 "+len+" 条记录吗？",yes);
				};
				
			});
			$( "#btn_export" ).on('click', function(e) {
				window.location.href='<%=basePath%>excel/w.xls';
			});
			$( "#btn_fresh" ).on('click', function(e) {
				$("#searchForm").submit();
			});
			function edit(id) {
				window.parent.showDialog("编辑供应商信息",'<%=basePath%>agent/agent_edit.do?id='+id,400,420);
			};
			function del(id) {
				var yes = function() {
					var url = '<%=basePath %>agent/agent_del.do?id='+id;
					$.post(url,function(){
						window.parent.showAlert("好吧，删了！");
						$("#searchForm").submit();
					});
				};
				window.parent.showConfirm("你确定要删除此条记录吗？",yes);
			};
			
			function GoToPage(toPage,totalPage) {
			    if(toPage<=0) return;
			    if(toPage>totalPage) return;
			    $("input[name='pageNumber']").val(toPage);
			    $("#searchForm").submit();
			};
		</script>
	</body>
</html>

